package com.ruoyi.web.controller.mdm;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mdm.domain.SkuChannelScore;
import com.ruoyi.mdm.service.ISkuChannelScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品指标渠道评分Controller
 *
 * @author shiseido
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/mdm/skuChannelScore")
public class SkuChannelScoreController extends BaseController {
    @Autowired
    private ISkuChannelScoreService skuChannelScoreService;

    /**
     * 查询产品指标渠道评分列表
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkuChannelScore skuChannelScore) {
        startPage();
        List<SkuChannelScore> list = skuChannelScoreService.selectSkuChannelScoreList(skuChannelScore);
        return getDataTable(list);
    }

    /**
     * 导出产品指标渠道评分列表
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:export')")
    @Log(title = "产品指标渠道评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkuChannelScore skuChannelScore) {
        List<SkuChannelScore> list = skuChannelScoreService.selectSkuChannelScoreList(skuChannelScore);
        ExcelUtil<SkuChannelScore> util = new ExcelUtil<SkuChannelScore>(SkuChannelScore.class);
        util.exportExcel(response, list, "产品指标渠道评分数据");
    }

    /**
     * 获取产品指标渠道评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(skuChannelScoreService.selectSkuChannelScoreById(id));
    }

    /**
     * 新增产品指标渠道评分
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:add')")
    @Log(title = "产品指标渠道评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkuChannelScore skuChannelScore) {
        return toAjax(skuChannelScoreService.insertSkuChannelScore(skuChannelScore));
    }

    /**
     * 修改产品指标渠道评分
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:edit')")
    @Log(title = "产品指标渠道评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkuChannelScore skuChannelScore) {
        return toAjax(skuChannelScoreService.updateSkuChannelScore(skuChannelScore));
    }

    /**
     * 删除产品指标渠道评分
     */
    @PreAuthorize("@ss.hasPermi('mdm:skuChannelScore:remove')")
    @Log(title = "产品指标渠道评分", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(skuChannelScoreService.deleteSkuChannelScoreByIds(ids));
    }
}
